import type { IResponse, IResponseRows } from '@/api/http'
import { get, put, del } from '@/api/http'
interface ISearch {
    title: string
    illustrate: string
    url: string
}
interface IMsg {
    msg: string
    url: string
    type: number
    time: string
    state: number
    id: number
}
interface IAppList {
    app_ava: string
    app_name: string
    app_info: string
    type: number
    price: number
    final_update_time: string
    release_time: string
    download: number
    version: number
    is_buy: number
    is_install: number
    banner: string[]
    intro: string[]
    special: string[]
    illustrate: string[]
    note: string[]
    update_log: [
        {
            update_time: string
            update_illustrate: string[]
            version: string
        },
    ]
}

export const headerSearch = (input: string) => {
    return get<IResponse<ISearch[]>>(
        `/header_search`,
        { input },
        { loading: false, showSuccessMessage: false },
    )
}

// 消息列表
export const headerMsg = (userId: number) => {
    return get<IResponse<IMsg[]>>(
        `/header_msg`,
        { userId },
        { loading: false, showSuccessMessage: false },
    )
}

// 修改状态
export const editHeaderMsgState = (id: number, params: IMsg) => {
    return put<IResponse<IMsg[]>>(
        `/header_msg/${id}`,
        {
            params,
        },
        {
            loading: false,
            showSuccessMessage: false,
        },
    )
}

// 删除已读消息
export const delHeaderMsg = (id: number) => {
    return del(`/header_msg/${id}`)
}

// 获取应用商店列表
export const getAppstore = (type?: number) => {
    return get<IResponseRows<IAppList>>(
        `/app_store`,
        { type: type },
        { loading: false, showSuccessMessage: false },
    )
}
